<template>
  <section>
    <el-pagination v-show="totalPage>0" style="margin-top:10px;" small
                   layout="prev, pager, next"
                   :page-count="totalPage"
                   @current-change="goPage">
    </el-pagination>
  </section>
</template>

<script>
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import errHandler from '@/assets/errHandler.js'
  import Vue from 'vue'//后续添加属性，需要vue联动
  export default {
    name: "periodLearnerInfo",
    props:['currPeriod'],
    data() {
      return {
        infoList:null,
        totalPage:0
      }
    },
    created(){
      console.log(this.currPeriod)
      this.getPeriodLearnerInfoList(0,this.currPeriod.id)
    },
    computed: {
      ...mapGetters(['department']),
    },
    watch:{},
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      goPage(val){
        this.getPeriodLearnerInfoList(val-1,this.currPeriod.id)
      },
      getPeriodLearnerInfoList(pageNo,periodId){
        this.fetch({name:"getPeriodLearnerInfoList",data:{page:pageNo?pageNo:0,periodId}})
          .then(res=>{
            console.log(res)
            this.infoList=res.content
            this.totalPage=res.totalPages
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
    }
  }
</script>

<style scoped>

</style>
